
<?php $javascript->link('googleSearch.js', false);?>
<?php $javascript->link('mktree.js', false);?>
<?php echo $html->css('mktree');?>

<div class="error-message">
<?php
$session->flash();
if($session->check('Message.auth'))
$session->flash('auth');
?>
</div>

<table class="frame_table">
<tr>
<td  width=250>
  <h2>Sample Ballot</h2>
<?php if (isset($_SESSION['ballotData'])) :?>
  	<?php $ballotData = $_SESSION['ballotData'];?>
<div class="ballots view">
<h1 align="left">Sample ballot for Zip <b><?php echo $ballotData['zip']?><?php if (!empty($ballotData['plus4'])): echo '-'.$ballotData['plus4']; endif;?></b> 
on <b><?php echo $ballotData['voteDate']?></b><br />
</h1>

<table class="side_table" cellpadding="0" cellspacing="0">
<?php
//print_r($ballotData);
$i = 0;
foreach ($ballotData['elections'] as $election):
$class = null;
if ($i++ % 2 == 0) {
  $class = ' class="altrow"';
}
?>
  <tr>
    <th colspan="2">
    <?php echo $election['name'].' '.$election['stage']?> Election
    </th>
  </tr>
  <tr>
    <td width="50%">
    <table class="frame_table" width="100%" align="left" cellspacing="0" cellpadding="0">
    <?php foreach ($election['offices'] as $office): ?>
      <tr>
        <td colspan="2">
        <h1><?php echo $office['Office']?>:</h1>
        </td>
      </tr>
      <?php foreach ($office['candidates'] as $candidate): ?>
      <tr>
        <?php $tdId = $candidate['firstName'].'-'.$candidate['lastName']?>
        <td style="text-align: right"> 
          <?php if (isset($candidate['like'])) {
            $attitude = $candidate['like'];
          }
          else {
            $attitude = null;
          }?>
          <?php echo $candidateSelector->makeSelector($candidate['firstName'], $candidate['lastName'], $attitude);?>
        </td>
        <td>
          <?php $candidateName = $candidate['firstName'].' '.$candidate['middleName'].' '.$candidate['lastName'];?>
          <a href="#" onclick="queryCandidate('<?php echo $candidateName?>', '<?php echo $candidate['party']?>')"
            title="<?php echo $candidateName.' - '.$candidate['party']?>">
            <?php echo $candidateName?>
          </a>
          </td>
      </tr>
      <?php endforeach;?>
      <?php endforeach;?>
    </table>
    </td>
  </tr>
  <?php endforeach;?>
  </table>
  <?php if (!empty($ballotData['measures'])): ?>
  <table class="side_table">
  <tr><th colspan="2">Ballot Measures</th></tr>
    <?php foreach ($ballotData['measures'] as $meas): ?>
    <tr>
    <td colspan="2"><h1><?php echo $meas['code'] ?></h1></td>
    </tr>
    <tr>
      <td></td>
      <td>
      <?php echo $meas['title'] ?>
      </td>
    </tr>
    <?php endforeach; ?>
  </table>  
  <?php else: ?>
  <hr>
  <h3>There are no measures on this ballot.</h3>
  <?php endif;?>

</div>
<?php endif;?>
<div class="ballots_form">
  <?php echo $form->create('Ballot', array('controller' => 'ballots', 'action' => 'getBallot'));?>
    Enter Zip code to get 
    <?php if (isset($_SESSION['ballotData'])) :?>
    new
    <?php endif;?>
    ballot<br/> 
    <input type="text" id="BallotZip" value="" name="data[Ballot][zip]" size="6" maxlength="6"/>
    -
    <input type="text" id="BallotZip" value="" name="data[Ballot][plus4]" size="4" maxlength="4"/>
    <input type="submit" value="Get Ballot"/>
  <?php echo $form->end();?>
</div>
</td>

<td>
  <h2>Learn about the candidates on various political issues from Google</h2>
 
    <b>VotesBy.US</b>
is a "front end" to Google that helps voters find, filter, and organize political information on the internet. <br/>

    <p>
    &nbsp;&nbsp;
    <a id="includePoliticsLink" style="font-size:small;"
      href="#" onclick="changeIncludePolitics()">
      <script type="text/javascript">
        document.write(includePolitics?"Add":"Remove");
      </script> key word "Politics"</a>
    &nbsp;
    <a id="includePartyLink" style="font-size:small;"
      href="#" onclick="changeIncludeParty()">
      <script type="text/javascript">
        document.write(includeParty?"Exclude":"Include");
      </script> Candidate's Party</a>
    </p>
    <div id="searchcontrol">
    </div>
    <div id="containerResults">
    </div>
</td>

<td width=200>
  <h2>Political Issues </h2>
      <form name="sortIssueForm">
        <select class="SmallText" name="jumpTo" onchange="sortIssues(this.value)">
          <option value="sortIssueByName">Sort by name</option>
          <option value="sortIssueBySearchReturn">Sort by search returns</option>
        </select>
      </form>
      <ul class="mktree" id="IssueTree">
      
    <?php foreach ($issues as $topissue => $subissues):?>
      <!-- <tr><th style="text-align: left"> -->
        <li  id="<?php echo("issue-".$topissue);?>">
        <a id="<?php echo("issue-link-".$topissue);?>"
            href="#" onclick="queryIssue('<?php echo($topissue);?>')">
          <?php echo($topissue);?> 
          <script type="text/javascript">
            issueList.push(<?php echo('"'.$topissue.'"');?>);
            //getQueryReturnCount(<?php echo('"'.$topissue.'"');?>);
          </script>
        </a>  
		      <ul>
		      <?php foreach ($subissues as $subissue):?>
		        <!-- <tr><td style="padding-left: 30px"> -->
		        <li>
		        <a href="#" onclick="queryIssue('<?php echo($subissue);?>')">
		            <?php echo($subissue);?>
		        </a>  
		        </li>
		      <!-- </td></tr> -->
          <?php endforeach;?>
          </ul>
        </li>
    <?php endforeach;?>
      </ul>
          <script type="text/javascript">
            refreshQueryReturnCount();
          </script>
    
</td>
</tr>
</table>
